#
# Copyright (C) 2017-2019 Chen Minqiang <ptpt52@gmail.com>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-natcap
PKG_VERSION:=5.0.1
PKG_RELEASE:=1

PKG_LICENSE:=GPLv3
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Chen Minqiang <ptpt52@gmail.com>

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/luci-app-natcap
	CATEGORY:=X
	SUBMENU:=Natcap Support
	TITLE:=LuCI Support for natcap
	PKGARCH:=all
	DEPENDS:=+natcapd +lua-cjson
endef

define Package/luci-app-natcap/description
	LuCI Support for natcap.
endef

define Build/Prepare
	$(foreach po,$(wildcard ${CURDIR}/files/luci/i18n/*.po), \
		po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
endef

define Build/Configure
endef

define Build/Compile
endef

define Package/luci-app-natcap/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
	rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
fi
exit 0
endef

define Package/luci-app-natcap/install
	$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
	$(INSTALL_DATA) $(PKG_BUILD_DIR)/natcap.*.lmo $(1)/usr/lib/lua/luci/i18n/
	$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
	$(INSTALL_DATA) ./files/luci/controller/*.lua $(1)/usr/lib/lua/luci/controller/
	$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/natcap
	$(INSTALL_DATA) ./files/luci/model/cbi/natcap/*.lua $(1)/usr/lib/lua/luci/model/cbi/natcap/
	$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/natcap
	$(INSTALL_DATA) ./files/luci/view/natcap/*.htm $(1)/usr/lib/lua/luci/view/natcap/
endef

$(eval $(call BuildPackage,luci-app-natcap))
